package com.hczt.fire.server.backend.sys.controller;

import com.hczt.fire.entity.sys.SysPermission;
import com.hczt.fire.server.backend.sys.service.SysPermissionService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * 把今天最好的表现当作明天最新的起点．．～
 * いま 最高の表現 として 明日最新の始発．．～
 * Today the best performance  as tomorrow newest starter!
 *
 * @author marvin.ma
 * @create 2017-10-19 23:13
 * @desc 权限
 **/
@Controller
@RequestMapping("/sys/permission")
public class SysPermissionController {

    private static final String BASE_PATH = "admin/sys/";

    @Resource
    private SysPermissionService sysPermissionService;

    /**
     * 跳转到权限列表页面
     * @return
     */
    @RequiresPermissions("permission:list")
    @GetMapping
    public String toList(){
        return BASE_PATH + "permission-list";
    }

    /**
     * 查询权限列表
     *
     * @return
     */
    @RequiresPermissions("permission:list")
    @ResponseBody
    @GetMapping("/list")
    public List<SysPermission> list(String menuName) {
        return sysPermissionService.findListByMenuName(menuName);
    }

}
